<style>
    .order-header-first {
        font-size: small;color: grey;
    }
    .order-header {
        font-size: small;color: grey;padding-left: 10%
    }
    .order-header-text {
        padding-left: 5px
    }
</style>
@foreach($paginator as $row)
    <div id="no_{{ $row->amazon_order_id }}" class="box box-default">
        <div class="box-header with-border" style="background-color: #f1f9fd">
            <span class="order-header-first">订单号</span><span class="order-header-text">{{ $row->amazon_order_id }}</span>
            <span class="order-header">商城</span><span class="order-header-text">{{ $row->marketplace_id }}</span>
            <span class="order-header">渠道</span><span class="order-header-text">{{ $row->sales_channel }}</span>
            <span class="order-header">下单时间</span><span class="order-header-text">{{ $row->purchase_date }}</span>
            <span class="order-header">状态</span><span class="order-header-text">{{ \App\Models\Amazon\AmazonOrder::$_orderStatus[$row->order_status] }}</span>
        </div>
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>账号</th>
                    <th>SKU</th>
                    <th>SKU名称</th>
                    <th>ASIN</th>
                    <th>币种</th>
                    <th>售价</th>
                    <th>促销费</th>
                    <th>数量</th>
                </tr>
                </thead>
                <tbody>

                <?php
                if (strtotime($row->purchase_date) >= strtotime('2023-12-01 00:00:00')) {
                    $row->items = \App\Models\Amazon\AmazonOrderItem::query()->where('amazon_order_id',$row->amazon_order_id)->get();
                }else{
                    $row->items = \App\Models\Amazon\AmazonOrderItemOld::query()->where('amazon_order_id',$row->amazon_order_id)->get();
                }
                ?>

                @foreach($row->items as $item)
                    <?php
                        $countryId = App\Models\Basics\AmazonCountry::getCountryIdByMarketplaceId($item->order->marketplace_id);
                        $amazonSku = App\Models\Product\ProductAmazonSku::query()->where(['seller_sku' => $item->sku, 'country_id' => $countryId])->first();;
                    ?>
                    <tr>
                        <td>{{ \App\Models\Basics\SysPlatAccount::getAccountById($item->account_id) }}</td>
                        <td>{{ $item->sku }}</td>
                        <td>{{ $amazonSku->sku->psku_cn ?? '' }}</td>
                        <td>{{ $item->asin }}</td>
                        <td>{{ $item->currency }}</td>
                        <td>{{ $item->price }}</td>
                        <td>{{ $item->promotion_discount }}</td>
                        <td>{{ $item->quantity }}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endforeach
